﻿Imports DTO
Imports System.Data.SqlClient

Public Class LoaiTaiKhoanDAO
    Public Function LayDSLoaiTaiKhoanDAO() As List(Of LoaiTaiKhoanDTO)
        Dim _listLoaiTK As New List(Of LoaiTaiKhoanDTO)

        Dim dt As New DataTable()

        Dim sql As String = "select * from LoaiTaiKhoan"
        dt = DataProvider.LoadSQL(sql)

        For Each row As DataRow In dt.Rows
            Dim _iMaLoaiTK As Integer = Integer.Parse(row("MaLoaiTK").ToString())
            Dim _sTenLoai As String = row("TenLoai").ToString()
            Dim _loaiTK As New LoaiTaiKhoanDTO(_iMaLoaiTK, _sTenLoai)
            _listLoaiTK.Add(_loaiTK)
        Next
        Return _listLoaiTK

    End Function

    Public Sub ThemLoaiTKDAO(ByVal _tenLoai As String)
        Dim _listPara As New List(Of SqlParameter)

        Dim sql As String = "sp_ThemLoaiTaiKhoan"

        Dim TenLoai As New SqlParameter("@TenLoai", SqlDbType.NVarChar)
        TenLoai.Value = _tenLoai
        _listPara.Add(TenLoai)

        DataProvider.ExcuteQueryProc(sql, _listPara)

    End Sub

    Public Sub XoaLoaiTKDAO(ByVal _maLoai As Integer)
        Dim _listPara As New List(Of SqlParameter)

        Dim sql As String = "sp_XoaLoaiTaiKhoan"

        Dim MaLoai As New SqlParameter("@MaLoai", SqlDbType.NVarChar)
        MaLoai.Value = _maLoai
        _listPara.Add(MaLoai)

        DataProvider.ExcuteQueryProc(sql, _listPara)

    End Sub
End Class
